package com.zhangshuo.common.validator;

import com.zhangshuo.common.annotation.In;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

import java.util.Arrays;

public class Invalidator implements ConstraintValidator<In, String> {
	private String[] values;

	@Override
	public void initialize(In constraintAnnotation) {
		values = constraintAnnotation.value();
	}

	@Override
	public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
		return Arrays.asList(values).contains(s);
	}
}
